from flask import Flask
from flask_sqlalchemy import SQLAlchemy

import os

app = Flask(__name__)

# app.config.from_object(config[config_name])
# config[config_name].init_app(app)

app.config['SECRET_KEY'] = 'hard to guess'
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root:chong@39.107.109.49:3390/triangle_server'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
app.config['UP'] = os.path.join(os.path.dirname(__file__), "static/uploads")
app.config['WECHAT_HTML'] = os.path.join(os.path.dirname(__file__), "static/htmls")

if not os.path.exists(app.config['UP']):
	os.makedirs(app.config['UP'])

if not os.path.exists(app.config['WECHAT_HTML']):
	os.makedirs(app.config['WECHAT_HTML'])


db = SQLAlchemy(app)

from .admin import admin as admin_blueprint
app.register_blueprint(admin_blueprint)

from .publisher import publisher as publisher_blueprint
app.register_blueprint(publisher_blueprint, url_prefix='/publisher')

from .user import user as user_blueprint
app.register_blueprint(user_blueprint, url_prefix='/user')

